package com.whu.tcx01.hd.calNewRoad;

import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class LineBean implements Writable {
    // 新的道路分为几段
    private long roadid;
    private int direction;
    private double distance;
    private int pathclass;
    private double speed;

    public long getRoadid() {
        return roadid;
    }

    public void setRoadid(long roadid) {
        this.roadid = roadid;
    }

    public int getDirection() {
        return direction;
    }

    public void setDirection(int direction) {
        this.direction = direction;
    }

    public double getDistance() {
        return distance;
    }

    public void setDistance(double distance) {
        this.distance = distance;
    }

    public int getPathclass() {
        return pathclass;
    }

    public void setPathclass(int pathclass) {
        this.pathclass = pathclass;
    }

    public double getSpeed() {
        return speed;
    }

    public void setSpeed(double speed) {
        this.speed = speed;
    }

    @Override
    public String toString() {
        return "["+roadid +"\t" + direction +"\t" + distance+"\t" + pathclass +"\t" + speed+"]";
    }

    //序列化的顺序和反序列化的顺序必须一致
    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeLong(roadid);
        dataOutput.writeInt(direction);
        dataOutput.writeDouble(distance);
        dataOutput.writeInt(pathclass);
        dataOutput.writeDouble(speed);
    }

    //反序列化的顺序
    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.roadid = dataInput.readLong();
        this.direction = dataInput.readInt();
        this.distance = dataInput.readDouble();
        this.pathclass = dataInput.readInt();
        this.speed = dataInput.readDouble();
    }
}
